/**
 *  用于路由跳转传递复杂对象
 *  注意⚠️：需主动声明想存储的位置 persist -> pick
 *
 */
import { defineStore } from 'pinia'

export const useTransferStore = defineStore('transfer', () => {
  const data = ref<any>(null)
  // 赛程筛选默认时间段
  const sportsEventTimeRang = ref('9')

  function setData(payload: any) {
    data.value = payload
  }

  function clear() {
    data.value = null
  }

  return {
    data,
    sportsEventTimeRang,
    setData,
    clear
  }
}, {
  persist: [
    {
      pick: ['data'],
      storage: localStorage,
    },
    {
      pick: ['sportsEventTimeRang'],
      storage: sessionStorage,
    },
  ],
})

if (import.meta.hot)
  import.meta.hot.accept(acceptHMRUpdate(useTransferStore, import.meta.hot))
